package com.ysq.www.api.front.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ysq.www.api.front.entity.Notice;
import com.ysq.www.api.front.service.INoticeService;
import com.ysq.www.common.annotation.AuthToken;
import com.ysq.www.common.result.ResultMsg;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 协会公告表 前端控制器
 * </p>
 *
 * @author dql
 * @since 2020-08-07
 */
@Slf4j
@RestController
@RequestMapping("/front/notice")
public class NoticeController {

    @Autowired
    private INoticeService noticeService;

    /**
     * 查询协会公告
     * @return
     */
    @GetMapping("/search")
    @AuthToken
    public ResultMsg searchBy(){
        QueryWrapper<Notice> wrapper = new QueryWrapper();
        wrapper.eq("status",0).orderByDesc("create_time").last("limit 3");
        List<Notice> nList = noticeService.list(wrapper);
        return ResultMsg.SUCCESS.setNewMsg("查询成功").setNewData(nList);
    }

    @PostMapping("/add")
    public ResultMsg addNotic(@RequestBody Notice notice ){
        


        return ResultMsg.INSERT_SUCCESS.setNewMsg("提交公告成功");
    }

}
